<?

require_once ("util/Transformer.php");
require_once ("util/Generator.php");


class JavaPolicyGen {
	public function show(){
		$transformer = new Transformer();
		$generator = new Generator();
		$transformer->setDirFisicoTemplates("template/");
		$transformer->setArquivoTemplate("esqueletoBase.htm");
		$valoresTroca = array ();
		$valoresTroca["titulo"] = $this->getTitulo();
		$valoresTroca["combo"] = $generator->getCombo();
		//$valoresTroca["header"] = $generator->getHeader();
		//$valoresTroca["menu"] = $generator->getMenu();
		//$valoresTroca["atalhos"] = $generator->getAtalhos("marcacao");
		$valoresTroca["footer"] = $generator->getFooter();
		$valoresTroca["erro"] = $generator->getErro();
		$valoresTroca["body"] = $this->getBody();
		$this->criarBat();
		
		$transformer->setValoresTroca($valoresTroca);
		$saida = $transformer->processaHTML();
		echo $saida;
	}
	private function getTitulo()
	{
		$titulo = "SIMweb :: Download";
		return $titulo;
	}

	private function getBody(){
		$transformer = new Transformer();
		$transformer->setDirFisicoTemplates("template/");
		$transformer->setArquivoTemplate("DownloadJavaPolicyGen.htm");
		$saida = $transformer->processaHTML();
		return $saida;
	}

	private function criarBat() {
		$transformer = new Transformer();
		$generator = new Generator();
		$transformer->setDirFisicoTemplates("template/");
		$transformer->setArquivoTemplate("baseJavaPolicyBat.txt");
		
		$valoresTroca['dirJava'] = $this->GetDirJava();
		
		$transformer->setValoresTroca($valoresTroca);
		$saida = $transformer->processaHTML();
		file_put_contents("temp/ConfigurarScanApllet.zip.bat",$saida);
	}
	private function GetDirJava(){
		$httpDirName = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/";
		return $httpDirName."java/";
	}
}

?>